package image

import (
	"context"
	"time"

	"go-weixin/app/guitar/api/internal/svc"
	"go-weixin/app/guitar/api/internal/types"
	"go-weixin/app/guitar/rpc/pb/proto/guitar"

	"github.com/zeromicro/go-zero/core/logx"
)

type GuitarImageUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGuitarImageUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GuitarImageUpdateLogic {
	return &GuitarImageUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GuitarImageUpdateLogic) GuitarImageUpdate(req *types.GuitarImageUpdateReq) (resp *types.GuitarImageUpdateResp, err error) {
	ctx, cannFunc := context.WithTimeout(context.Background(), time.Second*5)
	defer cannFunc()
	_, err = l.svcCtx.GuitarRPC.GuitarImageUpdate(ctx, &guitar.GuitarImageUpdateReq{
		Id:  req.Id,
		Url: req.Url,
	})
	resp = new(types.GuitarImageUpdateResp)
	return
}
